

<aside class="right-side">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Quản lí tin tức

        </h1>
       
        <ol class="breadcrumb">
            <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i> Quản lí</a></li>
            <li><a href="javascript:void(0);">Admin</a></li>
            <li class="active">Quản lí tin tức</li>
        </ol>
    </section>

    <!-- Main content -->
    <section class="content">

        <div class="row" id="catalogparent">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title"> <i class="fa fa-bars"></i> Danh sách tin tức</h3>
                        <div class="box-tools" style="float:right;">
                            <div class="input-group">
                                <input style="width: 250px;" type="text" name="key" id="key" placeholder="Nhập từ khóa cần tìm"/>
                                <a style="padding:3px 15px;background: #006600;color:#FFF;" href="javascript:void(0);" title="" onclick="loadcata();"><i class="fa fa-search"></i></a>
                                <a id="refeshbtn" style="padding:0px 10px;background: #006600;color:#FFF;border-radius: 3px;" href="javascript:void(0);" title=""><i class="fa fa-refresh"></i></a>
                            </div>

                        </div>

                    </div><!-- /.box-header -->
                    <div class="box-body table-responsive no-padding">
                        <input type="hidden" id="pageflag" value="1"/>
                        <table class="table table-hover">
                            <tr>
                                <th>STT</th>
                                <th>Tiêu đề</th>
                                <th>Mô tả</th>
                                <th>Ngày tạo</th>
                                <th>Trạng thái</th>
                                <th>#</th>
                            </tr>
                            <tbody id="listcata">

                            </tbody>
                            <tfoot>
                                <tr>
                                    <td colspan="7" id="findactive">
                                    </td>
                                </tr>
                            </tfoot>



                        </table>
                        <style>
                            .pageadmin{
                                width:auto;
                                height:25px;
                                float:left;
                                padding:0px 10px !important;
                                line-height: 23px;
                                background: #00ACEC;
                                color: #FFF;
                                border: #007bb6 solid 1px;
                                border-radius:3px;
                                margin-right:5px;
                            }
                            .pageadmin:hover,.activepage{
                                background: #007bb6;
                                color: #FFF;
                                border: #00ACEC solid 1px;
                            }
                        </style>
                    </div><!-- /.box-body -->
                </div><!-- /.box -->
            </div>
        </div>
        <!--meu parent -->

        <input type="hidden" value="<?php echo WEB_PATH; ?>/systemadmin/news/loadnews" id="urlshow"/>
   
        <input type="hidden" value="<?php echo WEB_PATH; ?>/systemadmin/news/delnews" id="urldel"/>
        <input type="hidden" value="<?php echo WEB_PATH; ?>/systemadmin/news/active" id="urlactive"/>
        <input type="hidden" value="<?php echo WEB_PATH; ?>/systemadmin/news/changeparent" id="urlchnageparent"/>
      

    </section><!-- /.content -->
</aside><!-- /.right-side -->
<script>

    $(document).ready(function() {
        loadcata();

        $("#refeshbtn").click(function() {
            $("#key").val("");
            loadcata();
        });

    });
    function setpage(page) {

        $("#pageflag").val(page);
        loadcata();
    }
    function loadcata() {
        var page = $("#pageflag").val();
        var key = $("#key").val();
        $.ajax({
            url: $("#urlshow").val(),
            type: "POST",
            cache: false,
            data: "action=load&page=" + page + "&key=" + key,
            success: function(dataserver) {
                var data = dataserver.split("*duypc*");
                $("#listcata").html(data[0]);
                $("#findactive").html(data[1]);
                $("#findactive").find("a").removeClass("activepage");
                $("#page" + page).addClass("activepage");
            }
        });
    }
    function delcatalog(newsId) {

        var mes = '<p class="warning-del">Bạn có muốn xóa dữ liệu này không?<br/>Quá trình này sẽ xóa hết các dữ liệu liên quan.</p><br/>' +
                '<span class="checkdel "><a onclick="confrimdel(' + newsId + ');" href="javascript:void(0);" class="ok">Xác nhận</a></span>' +
                '<span class="checkdel"> <a onclick="closedel();" href="javascript:void(0);" class="ok">Hủy</a></span>';
        $("#ctmes").html(mes);
        $("#warning").show();
    }
    function closedel() {
        $("#warning").hide();
    }
    function confrimdel(newsId) {
        var url = $("#urldel").val();
        $("#ctmes").html('<p class="warning-del">Đang xử lí...</p><br/>');
        $.ajax({
            url: url,
            type: "POST",
            cache: false,
            data: "action=delcatalog&newsId=" + newsId,
            success: function(dataserver) {
                var data = dataserver.split("*duypc*");

                var mes = '<p class="warning-del">' + data[1] + '</p><br/>' +
                        '<span class = "checkdel"><a onclick = "closedel();" href = "javascript:void(0);" class = "ok" > OK </a></span >';
                $("#ctmes").html(mes);
                if (data[0] == "delok") {
                    $("#" + newsId).remove();
                }
            }
        });
    }

    function setActive(videosId, active) {
        var url = $("#urlactive").val();
        $.ajax({
            url: url,
            type: "POST",
            cache: false,
            data: "action=load&videosId=" + videosId + "&active=" + active,
            success: function(dataserver) {
                loadcata();

            }
        });
    }
   </script>